package com.example.demo.exception;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;

import java.time.ZonedDateTime;

public class ApiExceptionHandler {
    @ExceptionHandler(value = ApiRequestException.class)
    public ResponseEntity<Object> handleApiRequestException(
            ApiRequestException e

    ){
        ApiException apiException =new ApiException(
                e.getMessage(),
                e, HttpStatus.NOT_FOUND,
                ZonedDateTime.now()
        )  ;
        return  new ResponseEntity<>(apiException,HttpStatus.NOT_FOUND);
    }
}

